package cloud.demo.eureka;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import cloud.demo.eureka.model.Product;

@RestController
public class ClientContrller {

	@Resource
	private ProductService productService;

	@Value("${client.msg}")
	private String clientMsg;

	@RequestMapping(value = "/", method = RequestMethod.GET)
	public Object home() {

		List<Product> products = productService.all();
		String serverInfo = productService.info();

		Map<String, Object> map = new HashMap<>();
		map.put("products", products);
		map.put("serverInfo", serverInfo);
		map.put("clientMsg", clientMsg);
		return map;
	}
}
